home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 3 / Cream of the Crop 3.iso / comm / spar372.zip / SPAR_DEV.ASM < prev    next >
Assembly Source File  |  1993-12-10  |  5KB  |  227 lines

  1. **
  2. ** $Source: DH1:network/parnet/Sana2/Sources/Spar_device.asm,v $
  3. ** $State: Exp $
  4. ** $Revision: 37.2 $
  5. ** $Date: 93/11/07 15:40:31 $
  6. ** $Author: S.A.Pechler $
  7. **
  8. ** Amiga SANA-II Example PARnet Device Driver
  9. **
  10. ** Based on the SANA-II Example SLIP Device Driver by kcd and rhslip.device by
  11. ** rhialto@mbfys.kun.nl (Olaf Seibert)
  12. **
  13. ** Portions (C) Copyright 1992 Commodore-Amiga, Inc.
  14. **
  15.  
  16.  
  17.     SECTION    firstsection
  18.  
  19.     NOLIST
  20.  
  21.     include    "exec/types.i"
  22.     include    "exec/devices.i"
  23.     include    "exec/initializers.i"
  24.     include    "exec/memory.i"
  25.     include    "exec/resident.i"
  26.     include    "exec/io.i"
  27.     include    "exec/ables.i"
  28.     include    "exec/errors.i"
  29.     include    "exec/tasks.i"
  30.     include    "utility/tagitem.i"
  31.     include    "dos/dos.i"
  32.     include    "dos/dosextens.i"
  33.     include    "dos/dostags.i"
  34.     include    "devices/sana2.i"
  35.  
  36.     LIST
  37.     include    "Spar_device.i"
  38.         include "Spar_rev.i"
  39.  
  40. ABSEXECBASE    EQU    4   ;Absolute location of the pointer to exec.library base
  41.  
  42. **
  43. ** Standard System Routines
  44. **
  45.  
  46.     XREF    _DevOpen
  47.     XREF    _DevClose
  48.     XREF    _DevExpunge
  49.     XREF    _DevBeginIO
  50.     XREF    _DevAbortIO
  51.  
  52. **
  53. ** Other misc. routines
  54. **
  55.     XDEF    _ExtDeviceBase
  56. **    XDEF    _DevProcEntry
  57.     XDEF    @IPToNum
  58. **    XDEF    _SANA2BuffCall
  59.     XREF    _DevProcCEntry
  60.     XREF    _SPARName
  61.     XREF    EndCode
  62.  
  63. **
  64. ** First executable location
  65. **
  66.  
  67. FirstAddress:
  68.     moveq    #-1,d0
  69.     rts
  70.  
  71. **
  72. ** A romtag structure. Your load module will be scanned for
  73. ** this structure to discover magic constants about you
  74. ** (such as where to start running you from...).
  75. **
  76.  
  77. ** Most people will not need a priority and should leave it at zero.
  78. ** The RT_PRI field is used for configuring the roms.
  79.  
  80. SPARPRI   EQU   5
  81.  
  82. initDDescrip:
  83.                         ; STRUCTURE RT,0
  84.     DC.W    RTC_MATCHWORD        ; UWORD    RT_MATCHWORD (Magic cookie)
  85.     DC.L    initDDescrip        ; APTR    RT_MATCHTAG  (Back pointer)
  86.     DC.L    EndCode            ; APTR    RT_ENDSKIP   (To end of this hunk)
  87.     DC.B    RTF_AUTOINIT        ; UBYTE    RT_FLAGS     (magic-see "Init:")
  88.     DC.B    VERSION            ; UBYTE    RT_VERSION
  89.     DC.B    NT_DEVICE        ; UBYTE    RT_TYPE         (must be correct)
  90.     DC.B    SPARPRI            ; BYTE    RT_PRI
  91.     DC.L    _SPARName        ; APTR    RT_NAME         (exec name)
  92.     DC.L    idString        ; APTR    RT_IDSTRING  (text string)
  93.     DC.L    Init            ; APTR    RT_INIT
  94.                             ; LABEL    RT_SIZE
  95.  
  96. ** This is an identifier tag to help in supporting the device
  97. ** format is 'name version.revision (dd MON yyyy)',<cr>,<lf>,<null>
  98.  
  99. idString:    VSTRING
  100.  
  101. ** Force word alignment
  102.  
  103.     CNOP    0,4
  104.  
  105. ** The romtag specified that we were "RTF_AUTOINIT". This means
  106. ** that the RT_INIT structure member points to one of these
  107. ** tables below. If the AUTOINIT bit was not set then RT_INIT
  108. ** would point to a routine to run.
  109.  
  110. Init:
  111.     DC.L    SPARDev_Sizeof    ; data space size
  112.     DC.L    DevFuncTable    ; pointer to function initializers
  113.     DC.L    DevDataTable    ; pointer to data initializers
  114.     DC.L    DevInit        ; routine to run
  115.  
  116. DevFuncTable:
  117.     dc.l    _DevOpen
  118.     dc.l    _DevClose
  119.     dc.l    _DevExpunge
  120.     dc.l    DevReserved
  121.     dc.l    _DevBeginIO
  122.     dc.l    _DevAbortIO
  123.     dc.l    -1
  124.  
  125. ** The data table initializes static data structures. The format is
  126. ** specified in exec/InitStruct routine's manual page. The
  127. ** INITBYTE/INITWORD/INITLONG macros are in the file "exec/initializers.i".
  128. ** The first argument is the offset from the device base for this
  129. ** byte/word/long. The second argument is the value to put in that cell.
  130. ** The table is null terminated.
  131.  
  132. DevDataTable:
  133.     INITBYTE    LN_TYPE,NT_DEVICE    ;Must be LN_TYPE!
  134.     INITLONG    LN_NAME,_SPARName
  135.     INITBYTE    LIB_FLAGS,LIBF_SUMUSED!LIBF_CHANGED
  136.     INITWORD    LIB_VERSION,VERSION
  137.     INITWORD    LIB_REVISION,REVISION
  138.     dc.l        0
  139.  
  140. **
  141. ** Rhialto: Our only global variable. Since it is constant as long as
  142. ** we're in existence, this is not harmful.
  143.  
  144. _ExtDeviceBase    dc.l    0
  145.  
  146. **
  147. ** initRoutine
  148. **
  149. ** This routine gets called after device has been allocated.
  150. ** The device pointer is in d0, the AmigaDOS segment list in a0.
  151. ** If it returns it's device pointer, then the device will be linked
  152. ** into the devices list. If it returns NULL, then the device will be
  153. ** unloaded.
  154. **
  155. ** This routine is single threaded
  156. **
  157. ** Register Usage
  158. **
  159. ** a3 - Pointer to temporary RAM
  160. ** a4 - Pointer to expansion.library base
  161. ** d0 - Pointer to device struct
  162. ** a6 - Pointer to Exec Base
  163.  
  164. DevInit:
  165.     movem.l    a0/a5,-(sp)
  166.     movea.l    d0,a5
  167.     move.l    d0,_ExtDeviceBase        ; Rhialto
  168.  
  169. ;    move.w    #REVISION,LIB_REVISION(a5)    ;already done in DevDataTable
  170.     move.l    a6,sd_SysLib(a5)    ;save a pointer to exec
  171.     move.l    a0,sd_SegList(a5)    ;save a pointer to our loaded code
  172.     lea.l    sd_Lock(a5),a0        ;make sure the Open() function
  173.     jsrlib    InitSemaphore        ;will be single-threaded.
  174.     move.l    a5,d0            ;return the device pointer
  175.     movem.l    (sp)+,a0/a5
  176.     rts
  177.  
  178. **
  179. ** Device Reserved vector (returns 0L)
  180. **
  181. DevReserved:
  182.     moveq.l    #0,d0
  183.     rts
  184.  
  185. @IPToNum:
  186.     movem.l    d2,-(sp)
  187.     bsr    StrToNum
  188.     lsl.w    #8,d0
  189.     move.w    d0,d2
  190.     bsr    StrToNum
  191.     move.b    d0,d2
  192.     swap    d2
  193.     bsr    StrToNum
  194.     lsl.w    #8,d0
  195.     move.w    d0,d2
  196.     bsr    StrToNum
  197.     move.b    d0,d2
  198.     move.l    d2,d0
  199.     movem.l    (sp)+,d2
  200.     rts
  201.  
  202. StrToNum:
  203.     moveq    #0,d0
  204.     moveq    #0,d1
  205. 1$    move.b    (a0)+,d1
  206.     cmp.b    #'0',d1
  207.     bcs.s    2$        ; was blo
  208.     cmp.b    #'9',d1
  209.     bhi    2$
  210.     sub.b    #'0',d1
  211.     mulu    #10,d0
  212.     add.w    d1,d0
  213.     bra    1$
  214. 2$    rts
  215.  
  216. ** These things are not needed anymore.
  217. **
  218. ** _SANA2BuffCall:
  219. **     jmp    (a2)
  220. **
  221. **_DevProcEntry:
  222. **    movea.l    _ExtDeviceBase(pc),a6
  223. **    jmp    _DevProcCEntry
  224.  
  225.  
  226.     END
  227.